import java.util.Arrays;
import java.util.List;

public class StreamExample {
    public static void main(String[] args) {
        List<Product> products = Arrays.asList(
                new Product("Laptop", 1200.0, "Electronics"),
                new Product("Mouse", 25.0, "Electronics"),
                new Product("Keyboard", 75.0, "Electronics"),
                new Product("Chair", 150.0, "Furniture"),
                new Product("Table", 250.0, "Furniture")
        );
        List<Product> expensiveProducts = products.stream()
                .filter(product -> product.getPrice() > 100.0)
                .toList();
        System.out.println("价格高于100的产品：\n" + expensiveProducts);


        List<String> ProductNames = products.stream()
                .map(product -> product.getName().toUpperCase())
                .toList();
        System.out.println("所以产品大写名字：\n" + ProductNames);


        List<Product> sotedByprice = products.stream()
                .sorted((p1, p2) -> Double.compare(p1.getPrice(), p2.getPrice()))
                .toList();
        System.out.println("按价格排序后的产品：\n"+sotedByprice);

        List<String>JKPX=products.stream()
                .filter(p->p.getPrice()>100)
                .map(Product::getName)
                .sorted()
                .toList();
        System.out.println("结果高于100且按名字排序：\n"+JKPX);



    }

    }

